package com.hg.design.behavior.visitor.biancheng.ex2;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

//对象结构角色:材料集
public class SetMaterial {
    private List<Material> list = new ArrayList<>();

    public String accept(Company visitor){
        Iterator<Material> i = this.list.iterator();
        String tmp = "";
        while (i.hasNext()) {
            tmp += i.next().accept(visitor) + " ";
        }
        return tmp;//返回某公司的作品集
    }

    public void add(Material material) {
        this.list.add(material);
    }

    public void remove(Material material) {
        this.list.remove(material);
    }
}
